package me.zk.practice1.s;

import java.util.List;

/**
 * 1-2-3
 * 1-2
 * 3-2
 *
 * @author zhangkai
 * @date 2023/7/31 09:23
 */
public class LS_Offer2_024 {
    public ListNode reverseList(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode pre = head;
        ListNode current = head.next;
        pre.next = null;
        while (current != null) {
          ListNode node = current.next;
          current.next = pre;
          pre = current;
          current = node;
        }
        return pre;
    }
}
